package com.luban.postprocessor;

import com.luban.service.OrderService;
import com.luban.service.UserService;

import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.stereotype.Component;

@Component
public class MyMergedBeanDefinitionPostProcessor implements MergedBeanDefinitionPostProcessor {
	@Override
	public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
		System.out.println(beanName + ":MyMergedBeanDefinitionPostProcessor:postProcessMergedBeanDefinition 刚实例化之后，进行属性值自动定设置 " + beanType);
		if (beanType.getName().equals(UserService.class.getName())) {
			OrderService orderService = new OrderService();
			System.out.println(beanName + ":MyMergedBeanDefinitionPostProcessor:postProcessMergedBeanDefinition 刚实例化之后，进行属性值自动定设置 " + beanType + ":orderService:" + orderService);
			beanDefinition.getPropertyValues().addPropertyValue("orderService", orderService);
		}
	}
}
